package com.config;

import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.unit.DataSize;
import org.springframework.util.unit.DataUnit;

import javax.servlet.MultipartConfigElement;

/**
 * @author xufan
 */
@Configuration
public class MultipartConfig {
    /**
     *  @author: xufan
     *  @Date: 2021/7/24
     *  @Description: 文件上传配置
     */
    @Bean
    public MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        //单个文件最大
        factory.setMaxFileSize(DataSize.of(100, DataUnit.MEGABYTES));
        ///设置总上传数据总大小
        factory.setMaxRequestSize(DataSize.of(1000,DataUnit.MEGABYTES));
        return factory.createMultipartConfig();
    }
}
